Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIP-39 import #285

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

webwarrior-ws
Copy link
Contributor

Implement the import in the backend using NBitcoin (BIP84 derivation path), with option to sweep the funds to a bitcoin account of geewallet with a transaction.

@knocte
Copy link
Member

knocte commented Jul 22, 2024

Still receiving this exception when testing:

Write the account number (or 0 to cancel): 1
System.Exception: Currency BTC not ether based and not UTXO either? not supported, report this bug (estimatefee)
   at [email protected](Unit unitVar) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Backend/Account.fs:line 221
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1139
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1166
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1515
   at GWallet.Frontend.Console.UserInteraction.AskFee(IAccount account, TransferAmount amount, String destination) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/UserInteraction.fs:line 608
   at GWallet.Frontend.Console.Program.TransferFundsFromWalletUsingMenmonic() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 408
   at GWallet.Frontend.Console.Program.WalletOptions() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 448
   at GWallet.Frontend.Console.Program.PerformOperation(UInt32 numActiveAccounts, UInt32 numHotAccounts) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 487
   at GWallet.Frontend.Console.Program.ProgramMainLoop[a]() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 564
   at GWallet.Frontend.Console.Program.NormalStartWithNoParameters() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 576

@webwarrior-ws webwarrior-ws force-pushed the bip-39-import branch 2 times, most recently from 07eae0c to db04387 Compare July 22, 2024 11:23
@knocte
Copy link
Member

knocte commented Jul 22, 2024

Another crash:

System.Exception: account 33deiowdoijdeiwjoiddeiowjodijew(BTC) not found in config, or more than one with same public address?
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1448.Invoke(String message)
   at GWallet.Frontend.Console.UserInteraction.DisplayAccountStatuses@386-14.Invoke(Currency arg20)
   at GWallet.Frontend.Console.UserInteraction.DisplayAccountStatuses@380-12.Invoke(Unit unitVar) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/UserInteraction.fs:line 386
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1139
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1166
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1515
   at [email protected](Unit unitVar0) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 386
   at GWallet.Frontend.Console.Program.TransferFundsFromWalletUsingMenmonic() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 406
   at GWallet.Frontend.Console.Program.WalletOptions() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 450
   at GWallet.Frontend.Console.Program.PerformOperation(UInt32 numActiveAccounts, UInt32 numHotAccounts) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 489
   at GWallet.Frontend.Console.Program.ProgramMainLoop[a]() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 566
   at GWallet.Frontend.Console.Program.NormalStartWithNoParameters() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 578

Please take in account the above address of mine corresponds to a READONLY account of mine.

@webwarrior-ws
Copy link
Contributor Author

@knocte
So we can't reuse DisplayAccountStatuses function. Easiest fix would be to make GetAccountBalance internal instead of private and use it together with DisplayAccountStatus to display account.

@webwarrior-ws
Copy link
Contributor Author

webwarrior-ws commented Jul 22, 2024

Or maybe list only normal (not readonly) accounts?

@knocte
Copy link
Member

knocte commented Jul 22, 2024

Easiest fix would be to make GetAccountBalance internal instead of private and use it together with DisplayAccountStatus to display account.

Sounds good

@knocte
Copy link
Member

knocte commented Jul 22, 2024

After sending the transaction, please add an invokation to the function that prints "Press any key to continue..." (like we do when we send normal transactions).

@knocte
Copy link
Member

knocte commented Jul 23, 2024

One last thing to do here: after sending the transaction to recover the funds, convert the ImportedAccount to an ArchivedAccount and save it to disk. This way, geewallet will warn the user if more funds arrive to it in the future.

@webwarrior-ws webwarrior-ws force-pushed the bip-39-import branch 2 times, most recently from ce686fb to a2db417 Compare July 23, 2024 12:36
@knocte
Copy link
Member

knocte commented Jul 24, 2024

This PR has 5 commits. The first one has CI red, so I think the most logical thing to do is squash the 1st one with the 2nd, to avoid that red CI status, and because those two commits are basically working on the same thing. Later, I would also squash commits 3 and 4. So, in the end, this PR can have 3 commits only.

Make native segwit default by always adding NATIVE_SEGWIT to
defined constants in configure.fsx.

To make tests work properly with native segwit, rename
deprecated OriginAddress property to OriginMainAddress
in test data.
Remove NATIVE_SEGWIT compile-time constant and all code that
was disabled when NATIVE_SEGWIT was defined.

Also remove readonly accounts migration to native segwit.
@webwarrior-ws webwarrior-ws force-pushed the bip-39-import branch 3 times, most recently from 0b5c686 to 881d7ac Compare July 24, 2024 09:51
@knocte
Copy link
Member

knocte commented Jul 26, 2024

@webwarrior-ws nit: before showing the possible accounts where to send the funds to, please add a Console.WriteLine invokation that informs the user about the address where the funds are.

Added option to import wallet using BIP39 seed phrase
(mnemonic). All funds from imported wallet (currently only
first receiving address is used) are sent to BTC account of
choice. After that, imported account is converted to archived
account so geewallet will warn the user if more funds arrive
to it in the future.
@webwarrior-ws
Copy link
Contributor Author

@webwarrior-ws nit: before showing the possible accounts where to send the funds to, please add a Console.WriteLine invokation that informs the user about the address where the funds are.

@knocte done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants